package com.holly.unit.deform.designer.kit;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 类描述: 字符串
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/8/2 11:02
 */
public class StrKit {

    private StrKit() {
        throw new UnsupportedOperationException("StrKit类无法实例化");
    }

    public static boolean isNum(String value) {
        boolean is = false;
        Pattern pattern = Pattern.compile("\\d+|\\d+\\.\\d+");
        Matcher matcher = pattern.matcher(value);
        if(matcher.matches()) {
            is = true;
        } else {
            is = false;
        }

        return is;
    }

    public static boolean isCheckRegex(String value, String regex) {
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(value);
        boolean is = m.matches();
        return is;
    }
    public static String handleNull(Object obj) {
        return null == obj?"":obj.toString().trim();
    }

    public static String handleNumNull(Object obj) {
        return null == obj?"0":obj.toString().trim();
    }
}
